<template>
  <a-menu :selectedKeys="[groupId || 'all']" @select="select">
    <a-menu-item key="all">{{this.$t('m.common.label.all')}}</a-menu-item>
    <a-menu-item v-for="item in list" :key="item.id">{{item.name}}</a-menu-item>
  </a-menu>
</template>

<script>

  export default {
    name: 'MarketGroup',
    props: {
      list: {
        type: Array,
        default: () => []
      },
      groupId: {
        type: String,
        default: null
      }
    },
    data () {
      return {}
    },
    methods: {
      select ({ item, key, selectedKeys }) {
        if (key == 'all') {
          this.$emit('select', null)
        } else {
          this.$emit('select', key)
        }
      }
    }
  }
</script>
